﻿@using AdverseEventReportSystem.BLL.SchedulingSystem
@using AdverseEventReportSystem.BLL
@{
    Layout = null;
    HolidayTypeSetting holidayTypeSetting = (HolidayTypeSetting)@Model;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="Cache" content="no-cache" />
    <title>假期类型详情</title>
    <link href="~/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="~/lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="~/lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
    <link href="~/Content/css/common.css" rel="stylesheet" type="text/css" />
    <script src="~/lib/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
    <script src="~/lib/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js?v=@DateTime.Now.ToString("yyyyMMdd")"></script>
    <style type="text/css">
        .gridtable { width: 370px; margin: 0px;  }
        .gridtable td { height: 30px;  line-height: 30px; }
    </style>
</head>
<body>
    <form>
        <div style="margin:10px 0px;">
            <table class="gridtable">
                <tr>
                    <td style="text-align:right; width:100px;">
                        假期类型：
                    </td>
                    <td>
                        <input type="text" id="txtHolidayName" name="txtHolidayName" class="l-text" style="width:250px;" value="@holidayTypeSetting.HolidayTypeName" />
                        <span style="color:#ff0000">*</span>
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right; width:100px;">
                        排序：
                    </td>
                    <td>
                        <input type="text" id="txtiSort" name="txtiSort" class="l-text" style="width:250px;" typeof="number" maxlength="5" value="@holidayTypeSetting.Sort" />
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right; width:100px;">
                        说明：
                    </td>
                    <td>
                        <textarea id="txtDescribe" name="txtDescribe" style="width:250px;" >@holidayTypeSetting.Describe</textarea>
                    </td>
                </tr>
                <tr style="display:none;">
                    <td style="text-align:right; width:100px;">
                        所属病区：
                    </td>
                    <td>
                        <input type="text" id="txtillArea" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align:center;padding-top:10px;">
                        <input id="btnSubmit" type="button" value="确定" class="l-button" />&nbsp;&nbsp;&nbsp;
                        <input id="btnClose" type="button" value="取消" class="l-button-cancel" />
                        <input type="hidden" id="hdnId" name="hdnId" value="@holidayTypeSetting.Id" />
                    </td>
                </tr>
                <tr></tr>
            </table>
        </div>       
    </form>
    <script type="text/javascript">
    var combobox;
    $(document).ready(function () {
        $("#btnClose").click(function () {
            frameElement.dialog.close();
        })
        $("#btnSubmit").click(function () {
            save();
        });
        $(":text[typeof=number]").keyup(function () {
            var c = $(this);
            if (/[^\d]/.test(c.val())) {
                var num = c.val().replace(/[^\d]/g, '');
                $(this).val(num == "" ? "" : parseInt(num));
            }
        });
        combobox = $("#txtillArea").ligerComboBox({
            width: 250,
            //data: [{ "value": 0, "text": "全部" }],
            url: '/Scheduling/SchedulingType/GetDepartmentList?ram=' + Math.random(),
            isMultiSelect: false,
            valueField: "value",
            textField: "text",
            value: '0',
            valueFieldID: 'hdnillArea',
            onSuccess: function (data) {
                combobox.insertItem({ "value": "0", "text": "-请选择-" }, 0);
                $("#txtillArea").ligerGetComboBoxManager().setValue("@LoginManager.GetLoginUser().CurrDepCode");
                if ("@holidayTypeSetting.DepartmentCode" != "" && "@holidayTypeSetting.DepartmentCode"!="0") {
                    $("#txtillArea").ligerGetComboBoxManager().setValue("@holidayTypeSetting.DepartmentCode");
                }
                $(":input[type=text]:first").focus();
                dataformInit = $("form").serializeArray();
                jsonTextInit = JSON.stringify({ dataform: dataformInit });
            }
        });
    })
    var dataformInit;
    var jsonTextInit;
    function save() {
        //var dataform = $("form").serializeArray();
        //var jsonText = JSON.stringify({ dataform: dataform });
        //if (jsonTextInit == jsonText && parseInt($("#hdnId").val()) > 0) {
        //    var manager1 = $.ligerDialog.waitting('保存成功...');
        //    setTimeout(function () {
        //        manager1.close();
        //        frameElement.dialog.close();
        //    }, 1000);
        //    return false;
        //}
        if ($("#txtiSort").val == "") $("#txtiSort").val(1);
        if (IsEmpty($("#txtHolidayName").val())) { $.ligerDialog.error("请输入假期类型"); $("#txtHolidayName").select(); return; }
        var arr = $("form").serializeArray();
        var obj = {};
        for (var i = 0; i < arr.length; i++) {
            obj[arr[i].name] = arr[i]['value']
        }
        $.post("/Scheduling/HolidayType/Save", obj, function (data, textStatus) {
            if (textStatus == "success") {
                var d = $.parseJSON(data);
                if (d.Result == 1) {
                    parent.window.btnSearch.click();
                    $.ligerDialog.success("保存成功");
                    frameElement.dialog.close();
                }
                else if (d.Result == 0) {
                    $.ligerDialog.error(d.Body);
                }
                else {
                    $.ligerDialog.error("程序错误");
                }
            } else { $.ligerDialog.error("程序错误"); }
        })
    }
    </script>
</body>
</html>
